// MESSAGE MOTOR_CTRL support class

#pragma once

namespace mavlink {
namespace fppa {
namespace msg {

/**
 * @brief MOTOR_CTRL message
 *
 * MOTOR_CTRL
 */
struct MOTOR_CTRL : mavlink::Message {
    static constexpr msgid_t MSG_ID = 180;
    static constexpr size_t LENGTH = 18;
    static constexpr size_t MIN_LENGTH = 18;
    static constexpr uint8_t CRC_EXTRA = 230;
    static constexpr auto NAME = "MOTOR_CTRL";


    uint8_t cmd; /*<  commands */
    uint8_t addr; /*<  motor number */
    float pos; /*<  motor position */
    float pos1; /*<  motor position */
    float res1; /*<  res1 */
    float res2; /*<  res2 */


    inline std::string get_name(void) const override
    {
            return NAME;
    }

    inline Info get_message_info(void) const override
    {
            return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
    }

    inline std::string to_yaml(void) const override
    {
        std::stringstream ss;

        ss << NAME << ":" << std::endl;
        ss << "  cmd: " << +cmd << std::endl;
        ss << "  addr: " << +addr << std::endl;
        ss << "  pos: " << pos << std::endl;
        ss << "  pos1: " << pos1 << std::endl;
        ss << "  res1: " << res1 << std::endl;
        ss << "  res2: " << res2 << std::endl;

        return ss.str();
    }

    inline void serialize(mavlink::MsgMap &map) const override
    {
        map.reset(MSG_ID, LENGTH);

        map << pos;                           // offset: 0
        map << pos1;                          // offset: 4
        map << res1;                          // offset: 8
        map << res2;                          // offset: 12
        map << cmd;                           // offset: 16
        map << addr;                          // offset: 17
    }

    inline void deserialize(mavlink::MsgMap &map) override
    {
        map >> pos;                           // offset: 0
        map >> pos1;                          // offset: 4
        map >> res1;                          // offset: 8
        map >> res2;                          // offset: 12
        map >> cmd;                           // offset: 16
        map >> addr;                          // offset: 17
    }
};

} // namespace msg
} // namespace fppa
} // namespace mavlink
